/**
 * 
 */
package Sources;

import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;


import Factory.SFac;
import junit.framework.TestCase;

/**
 * @author Shinichi
 *
 */
public class SourcesDBtest extends TestCase {

	private SourcesDB sou=new SourcesDB();
	String path="F:\\test\\";
	String q="SELECT s FROM sourcesdef s WHERE s.path LIKE '"+path.replace('\\','_')+"'";
	String[] expStrings={"*"};
	SessionFactory factory=SFac.get();
	/**
	 * Adding one source 
	 */
	public void test1(){
		sou.insertSource(path,expStrings);
		Session session=factory.openSession();
		Query query=session.createQuery(q);
		assertEquals(true,query.list().size()>0);
		session.flush();
		session.close();
	}
	/**
	 * Removing it
	 */
	public void test2(){
		try{
			sou.deleteSource(path);
		}catch (Exception e) {}
		Session session=factory.openSession();
		Query query=session.createQuery(q);
		assertEquals(true,query.list().size()==0);
		session.flush();
		session.close();
	}


}
